package com.dubbo.aop;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @ Author xsd
 * @ crate time 2020/6/28 16:37
 * @ 描述 切 rpc bean
 * zj: 切 real bean__proxy bean
 *    _@Around：环绕增强，相当于MethodInterceptor
 *    _@AfterReturning：后置增强，相当于AfterReturningAdvice，方法正常退出时执行
 *    _@Before：标识一个前置增强方法，相当于BeforeAdvice的功能，相似功能的还有
 *    _@AfterThrowing：异常抛出增强，相当于ThrowsAdvice
 *    _@After: final增强，不管是抛出异常或者正常退出都会执行
 */
@Aspect
@Component
@Slf4j
public class Aop {

    @Pointcut("execution(public * com.dubbo.service.PrividerMessageService.*(..)))")
    public void queryDataPoint() {

    }

    @Around("queryDataPoint()")
    public Object doAroundAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        log.info("老弟，来了哈");
        return proceedingJoinPoint.proceed();
    }

    @Before("queryDataPoint()")
    public void logBefore(JoinPoint joinPoint) {
        log.info("before ->:"+joinPoint);
    }
    @After("queryDataPoint()")
    public void logAfter(JoinPoint joinPoint) {
        log.info("after ->:"+joinPoint);
    }
}
